package ArrayListTest.homework;

import java.util.Arrays;
import java.util.List;

/**
 * 数组转换为集合
 */
public class ArrayToList {
    public static void main(String[] args) {
        String[] array = {"one","two","three","four","five"};
        System.out.println(Arrays.toString(array));//[one, two, three, four, five]

        //asList()方法
        List<String> list = Arrays.asList(array);
        System.out.println(list);//[one, two, three, four, five]

        //修改集合
        list.set(1,"two2");
        System.out.println(list);//[one, two2, three, four, five]
        System.out.println(Arrays.toString(array));//[one, two2, three, four, five]

        //修改数组
        array[3] = "four2";
        System.out.println(list);//[one, two2, three, four2, five]
        System.out.println(Arrays.toString(array));//[one, two2, three, four2, five]
    }
}
